<?php if (!defined('SERVER_ROOT')) {exit('No direct script access allowed');}
//header
$this->template->title = 'Tra cứu hồ sơ';
$this->template->display('dsp_header.php');
$TYPE='TEN_TAT';
$TEN_TAT = '';
$MA_THU_TUC = '0';
while ($arr = $arr_single_thutuc->FetchRow()){
    $TEN_TAT =  $arr['TEN_TAT'];
    $MA_THU_TUC =  $arr['MA_THU_TUC'];
}
$v_TRANG_THAI_HO_SO_filter= $arr_filter['hdn_TRANG_THAI_HO_SO_filter'];
$v_SO_HO_SO= $arr_filter['txt_SO_HO_SO'];
$v_SO_BIEN_NHAN= $arr_filter['txt_SO_BIEN_NHAN'];
$v_TEN_CONG_DAN= $arr_filter['txt_TEN_CONG_DAN'];
$v_CMND_CONG_DAN= $arr_filter['txt_CMND_CONG_DAN'];
$v_DI_DONG_CONG_DAN= $arr_filter['txt_DI_DONG_CONG_DAN'];
$v_DIA_CHI_CONG_DAN= $arr_filter['txt_DIA_CHI_CONG_DAN'];
$v_VE_VIEC= $arr_filter['txt_VE_VIEC'];
$v_MA_DON_VI_TIEP_NHAN= $arr_filter['cbx_MA_DON_VI_TIEP_NHAN'];
$v_NHAN_TU_NGAY= $arr_filter['txt_NHAN_TU_NGAY'];
$v_NHAN_DEN_NGAY= $arr_filter['txt_NHAN_DEN_NGAY'];
$v_HEN_TRA_TU_NGAY= $arr_filter['txt_HEN_TRA_TU_NGAY'];
$v_HEN_TRA_DEN_NGAY= $arr_filter['txt_HEN_TRA_DEN_NGAY'];
$v_NAM= $arr_filter['cbx_NAM'];
$v_MA_DON_VI_XU_LY= $arr_filter['cbx_MA_DON_VI_XU_LY'];

?>
<style>
.div_menu_tracuu{
    float:left;
    position: relative;
    width: 20%;
    height: 330px;
    padding: 10px;
    border: 1px solid #0079b2;
}
 .div_menu_tracuu li{
    border-bottom:  1px dashed #CE0000;
    list-style: circle;
    text-indent: 0px;
    line-height: 1.5em;
    padding: 2px 5px 1px 0px;
    margin-left: 15px;
}
.div_menu_tracuu a, a:hover, a:visited{
    text-decoration: none;
}
.div_menu_tracuu a:hover{
    text-decoration:underline;
    color: #009966;
}
 .active{
    text-decoration:underline;
    color: #FF0000;
}
.div_right_tracuu{
    float:right;
    width: 74%;
    position: relative;
    border: 1px solid #0079b2;
    padding: 10px;
    height: 330px;
}
</style>

<form name="frmMain" id="frmMain" action="" method="POST" enctype="multipart/form-data">
  <?php
        echo $this->hidden('controller', $this->get_controller_url());
        echo $this->hidden('hdn_TYPE_filter', 'MA_THU_TUC');//mặc định search theo MA_THU_TUC =0
        echo $this->hidden('hdn_TRANG_THAI_HO_SO_filter',$v_TRANG_THAI_HO_SO_filter );
        $namhientai=date('Y');
        $n=2012;
        $v_row=0;
    ?>
<div class="div_menu_tracuu">
    <div class="menuLeft" id="menuLeft">
        <ul>
            <div>
            <?php while ($arr = $arr_menu_search->FetchRow()): ?>
            <?php
             $TRANG_THAI_HO_SO=$arr['TRANG_THAI_HO_SO'];
             $TEN_TRANG_THAI_HO_SO=$arr['TEN_TRANG_THAI_HO_SO'];
             $SO_LUONG=$arr['SO_LUONG'];
            ?>
             <li  class="menuLeft-item">
                <a id="trangthai<?php echo $TRANG_THAI_HO_SO; ?>
                "href="javascript:void(0)"
                <?php if ($v_TRANG_THAI_HO_SO_filter== $TRANG_THAI_HO_SO):?>
                  class="active"
                <?php else:?>
                  class="normal"
                <?php endif?>

                onclick="search_trangthai_click('<?php echo $TRANG_THAI_HO_SO;?>')">
                <?php echo $TEN_TRANG_THAI_HO_SO; ?></a>[<span style="color:red"><?php echo $SO_LUONG;?></span>]
             </li>
            <?php endwhile; ?>
            </div>

        </ul>
    </div>
</div>

<div class="div_right_tracuu">
    <div style="text-align: center">
    <b>TRA CỨU HỒ SƠ TIẾP NHẬN NĂM</b>
    <select data-doc="no" data-xml="no" data-name="Loại hồ sơ"
                  data-validate="text" data-allownull="no"
                  onchange="cbx_NAM_onchange(this)"
                  style="color: #000000;"
                  id="cbx_NAM" name="cbx_NAM">
                 <option value="0" selected="selected">Tất cả</option>
                    <?php while ($n<=$namhientai): ?>
                        <?php
                         $NAM=$n;
                         $n=$n+1;
                        ?>
                         <?php if($v_NAM == $NAM):?>
                           <option value="<?php echo $NAM; ?>" selected="selected"><?php echo $NAM; ?></option>
                        <?php else:?>
                           <option value="<?php echo $NAM; ?>" ><?php echo $NAM; ?></option>
                        <?php endif ?>
                    <?php endwhile; ?>
    </select>
    <b>ĐƠN VỊ XỬ LÝ </b>
    <select data-doc="no" data-xml="no" data-name="Loại hồ sơ"
                  data-validate="text" data-allownull="no"
                  onchange="tracuu_click()"
                  style="color: #000000;"
                  id="cbx_MA_DON_VI_XU_LY" name="cbx_MA_DON_VI_XU_LY">
                    <?php while ($arr = $arr_all_donvi_xuly->FetchRow()): ?>
                        <?php
                         $MA=$arr['MA_DON_VI'];
                         $TEN=$arr['TEN_DON_VI'];
                        ?>
                         <?php if($v_MA_DON_VI_XU_LY == $MA):?>
                           <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                        <?php else:?>
                           <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                        <?php endif ?>
                        <?php endwhile; ?>
    </select>
    </div>
	<div id="div_filter">
    <input type="text" data-doc="no" data-xml="no"
                   data-name="Loại hồ sơ" data-validate="text"
                   accesskey="1"
                   onkeypress="txt_TEN_TAT_filter_onkeypress(event);"
                   maxlength="10" size="10"  class="inputbox upper_text"
                   value="<?php echo $TEN_TAT;?>" id="txt_TEN_TAT_filter"
                   name="txt_TEN_TAT_filter"  style="width:8%"
                   onkeyup="ConverUpperCase('txt_TEN_TAT_filter',this.value)">

     <select data-doc="no" data-xml="no" data-name="Loại hồ sơ"
                  data-validate="text" data-allownull="no"
                  onchange="cbx_MA_THU_TUC_filter_onchange(this)"
                  style="width: 90%; color: #000000;"
                  id="cbx_MA_THU_TUC_filter" name="cbx_MA_THU_TUC_filter">
                    <?php while ($arr = $arr_all_thutuc_dathuchien->FetchRow()): ?>
                        <?php
                         $MA=$arr['MA_THU_TUC'];
                         $TEN=$arr['TEN_THU_TUC'];
                        ?>
                         <?php if($MA_THU_TUC == $MA):?>
                           <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                        <?php else:?>
                           <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                        <?php endif ?>
                    <?php endwhile; ?>
    </select>
    </div>
    <table id="tbl_thongtinnguoinop" cellspacing='5px' cellpadding='2px'
           class="none-border-table"
           style="width: 100%; line-height: 200% ">
		<tbody>
        <tr>
			<td width="15%">Mã hồ sơ: </td>
			<td width="35%">
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_SO_HO_SO; ?>"
                   style="width: 95%"  autofocus="autofocus"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_SO_HO_SO" name="txt_SO_HO_SO">
            </td>
           	<td width="15%">Số biên nhận: </td>
			<td width="35%">
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_SO_BIEN_NHAN; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_SO_BIEN_NHAN" name="txt_SO_BIEN_NHAN">
            </td>
        </tr>
        <tr>
			<td >Tên người nộp: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_TEN_CONG_DAN; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="50" id="txt_TEN_CONG_DAN" name="txt_TEN_CONG_DAN">
            </td>
           	<td>CMND: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_CMND_CONG_DAN; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="9" id="txt_CMND_CONG_DAN" name="txt_CMND_CONG_DAN">
            </td>
        </tr>
        <tr>
			<td >Di động: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_DI_DONG_CONG_DAN; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="11" id="txt_DI_DONG_CONG_DAN" name="txt_DI_DONG_CONG_DAN">
            </td>
           	<td>Địa chỉ: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_DIA_CHI_CONG_DAN; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="100" id="txt_DIA_CHI_CONG_DAN" name="txt_DIA_CHI_CONG_DAN">
            </td>
        </tr>
        <tr>
			<td >Về việc: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_VE_VIEC; ?>"
                   style="width: 95%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="100" id="txt_VE_VIEC" name="txt_VE_VIEC">
            </td>
            <td>ĐV tiếp nhận: </td>
			<td>
            <select id="cbx_MA_DON_VI_TIEP_NHAN"
            onchange="tracuu_click()"
            name="cbx_MA_DON_VI_TIEP_NHAN" style="width:97%">
                        <?php while ($arr = $arr_all_donvi_motcuaxa->FetchRow()): ?>
                        <?php
                         $MA=$arr['MA_DON_VI'];
                         $TEN=$arr['TEN_DON_VI'];
                        ?>
                         <?php if($v_MA_DON_VI_TIEP_NHAN == $MA):?>
                           <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                        <?php else:?>
                           <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                        <?php endif ?>
                        <?php endwhile; ?>
            </select>
            </td>
        </tr>
        <tr>
			<td >Nhận từ ngày: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_NHAN_TU_NGAY; ?>"
                   style="width: 80%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_NHAN_TU_NGAY" name="txt_NHAN_TU_NGAY">
              <img class="btndate" style="cursor:pointer" id="btnDate" src="<?php echo SITE_ROOT; ?>public/images/calendar.gif" onclick="DoCal('txt_NHAN_TU_NGAY')">
            </td>
           	<td>Đến ngày: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_NHAN_DEN_NGAY; ?>"
                   style="width: 80%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_NHAN_DEN_NGAY" name="txt_NHAN_DEN_NGAY">
              <img class="btndate" style="cursor:pointer" id="btnDate" src="<?php echo SITE_ROOT; ?>public/images/calendar.gif" onclick="DoCal('txt_NHAN_DEN_NGAY')">
           </td>
        </tr>
        <tr>
			<td >Hẹn trả từ ngày: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_HEN_TRA_TU_NGAY; ?>"
                   style="width: 80%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_HEN_TRA_TU_NGAY" name="txt_HEN_TRA_TU_NGAY">
             <img class="btndate" style="cursor:pointer" id="btnDate" src="<?php echo SITE_ROOT; ?>public/images/calendar.gif" onclick="DoCal('txt_HEN_TRA_TU_NGAY')">
           </td>
           	<td>Đến ngày: </td>
			<td>
            <input type="text" data-doc="no" data-xml="no"
                   data-name="CMND" data-validate="text"
                   data-allownull="no" value="<?php echo $v_HEN_TRA_DEN_NGAY; ?>"
                   style="width: 80%"
                   onkeypress="txt_SEARCH_onkeypress(event);"
                   maxlength="20" id="txt_HEN_TRA_DEN_NGAY" name="txt_HEN_TRA_DEN_NGAY">
            <img class="btndate" style="cursor:pointer" id="btnDate" src="<?php echo SITE_ROOT; ?>public/images/calendar.gif" onclick="DoCal('txt_HEN_TRA_DEN_NGAY')">
            </td>
        </tr>
      	</tbody>
      </table>
       <div style="text-align: center;margin-top: 10px;">
          <input onclick="tracuu_click()" id="btn_add_hoso" type="button" accesskey="2"  value="Tra cứu" class="button" name="update">
          <input onclick="xoahet_click()" id="btn_add_hoso" type="button" accesskey="2"  value="Xóa hết" class="button" name="update">
       </div>
</div>
<table width="100%" class="adminlist" cellspacing="0" border="1">
        <colgroup>
            <col width="9%">
            <col width="15%">
            <col width="28%">
            <col width="8%">
            <col width="15%">
            <col width="15%">
            <col width="10%">
        </colgroup>
        <tbody>
        <tr>
            <th>Mã hồ sơ</th>
            <th>Người đăng ký</th>
            <th>Địa chỉ</th>
            <th>Thời hạn</th>
            <th>Ngày giờ tiếp nhận</th>
            <th>Ngày giờ hẹn trả</th>
            <th>Thao tác</th>
        </tr>
        <?php while ($arr = $arr_all_hoso->FetchRow()): ?>
            <?php
             $MA_HO_SO=$arr['MA_HO_SO'];
             $SO_HO_SO=$arr['SO_HO_SO'];
             $TEN_CONG_DAN_NOP=$arr['TEN_CONG_DAN_NOP'];
             $DIA_CHI_CONG_DAN_NOP=$arr['DIA_CHI_CONG_DAN_NOP'];
             $TGQD_HO_SO=$arr['TGQD_HO_SO'];
             $NGAY_GIO_TIEP_NHAN=$arr['NGAY_GIO_TIEP_NHAN'];
             $NGAY_GIO_HEN_TRA=$arr['NGAY_GIO_HEN_TRA'];
             $SO_LAN_IN_PTN=$arr['SO_LAN_IN_PTN'];
             $LY_DO_HUY=$arr['LY_DO_HUY'];
             $v_class = 'row' . ($v_row % 2);
             $v_row++;
             $v_link = SITE_ROOT . 'hoso/tracuu/dsp_single_hoso/&m=' . $MA_HO_SO;
             $v_link2 = SITE_ROOT . 'hoso/tracuu/dsp_qths/&m=' . $MA_HO_SO.'&s=' . $SO_HO_SO;
             if ($LY_DO_HUY!=''){
              $v_popup = '<b>Lý do từ chối:</b> <br/>'. $LY_DO_HUY;
             }else{
               $v_popup='';
             }
            ?>
            <tr  class="<?php echo $v_class;?>">
                <td style="text-align:center;vertical-align:middle">
                   <b><a
                         <?php if ($v_popup!=''):?>
                            class="personPopupTrigger" rel="<?php echo $v_popup;?>"
                         <?php else:?>
                            title="Click vào đây để xem chi tiết hồ sơ"
                         <?php endif?>
                         href="<?php echo $v_link;?>"><?php echo $SO_HO_SO;?></a></b>
                </td>
                <td style="vertical-align:middle"><?php echo $TEN_CONG_DAN_NOP;?></td>
                <td style="vertical-align:middle"><?php echo $DIA_CHI_CONG_DAN_NOP;?></td>
                <td style="vertical-align:middle"><?php echo $TGQD_HO_SO;?></td>
                <td style="text-align:center;vertical-align:middle"><?php echo $NGAY_GIO_TIEP_NHAN;?></td>
                <td style="text-align:center;vertical-align:middle"><?php echo $NGAY_GIO_HEN_TRA;?></td>
                <td style="text-align:center;vertical-align:middle">
                    <a target="_blank" href="<?php echo $v_link2;?>" title="Xem qui trình và tiến độ giải quyết hồ sơ này">Tiến độ</a>
                </td>
            </tr>
        <?php endwhile; ?>
        <?php echo $this->add_empty_rows($v_row +1, _CONST_DEFAULT_ROWS_PER_PAGE, 7); ?>
</table>
</form>
<script>
    function cbx_NAM_onchange(e){
       var f = document.frmMain;
       f.hdn_TYPE_filter.value =  'MA_THU_TUC';
       f.submit();
    }
    function txt_TEN_TAT_filter_onkeypress(evt){
        if (IE()){
            theKey=window.event.keyCode
        }else{
            theKey=evt.which;
        }
        if(theKey == 13){
            if ( trim($("#txt_TEN_TAT_filter").val()) == ''){
                $("#cbx_MA_THU_TUC_filter").val('0');
            }
            var f = document.frmMain;
            f.hdn_TYPE_filter.value =  'TEN_TAT';
            f.txt_TEN_TAT_filter.value = trim($("#txt_TEN_TAT_filter").val()).toUpperCase();
            f.submit();
        }
        return false;
    }
    function cbx_MA_THU_TUC_filter_onchange(e){
        if (trim(e.value) == '0'){
            e.form.txt_TEN_TAT_filter.value ='';
         }
       var f = document.frmMain;
       f.hdn_TYPE_filter.value =  'MA_THU_TUC';
       f.submit();
    }
    function search_trangthai_click(trangthaihoso){
        var f = document.frmMain;
        f.hdn_TYPE_filter.value =  'MA_THU_TUC';
        f.hdn_TRANG_THAI_HO_SO_filter.value =  trangthaihoso;
        f.submit();
    }

    function txt_SEARCH_onkeypress(evt){
        if (IE()){
            theKey=window.event.keyCode
        }else{
            theKey=evt.which;
        }
        if(theKey == 13){
            var f = document.frmMain;
            f.hdn_TYPE_filter.value =  'MA_THU_TUC';
            f.submit();
        }
        return false;
    }
    function xoahet_click(){
        $("#txt_SO_HO_SO").val('');
        $("#txt_SO_BIEN_NHAN").val('');
        $("#txt_TEN_CONG_DAN").val('');
        $("#txt_CMND_CONG_DAN").val('');
        $("#txt_DI_DONG_CONG_DAN").val('');
        $("#txt_DIA_CHI_CONG_DAN").val('');
        $("#txt_VE_VIEC").val('');
        $("#cbx_MA_DON_VI_TIEP_NHAN").val('');
        $("#txt_NHAN_TU_NGAY").val('');
        $("#txt_NHAN_DEN_NGAY").val('');
        $("#txt_HEN_TRA_TU_NGAY").val('');
        $("#txt_HEN_TRA_DEN_NGAY").val('');
    }
    function tracuu_click(){
        var f = document.frmMain;
        f.hdn_TYPE_filter.value =  'MA_THU_TUC';
        f.submit();
    }
</script>
<?php $this->template->display('dsp_footer.php');